package com.cm.mapper;

import com.cm.pojo.Emp;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestParam;

import java.time.LocalDate;
import java.util.List;

/**
 * ClassName:  EmpMapper
 * Package: com.cm.mapper
 * Description:
 *
 * @Author:
 * @Create: 2025/8/10  4:10
 * @Version 1.0
 */
@Mapper
public interface EmpMapper {

// --------------------- 分页的原始sql----------------------------
/**
 * 查询总记录数
 */
//    @Select("select count(1)  from emp left join dept on emp.dept_id = dept.id ")
//    public Long count();
/**
 * 分页查询所有员工
 */
//    @Select("select e.*,d.name deptName from emp e left join dept d " +
//            "on e.dept_id = d.id order by update_time desc limit #{start},#{pageSize}")
//
//    public List<Emp> list(Integer start, Integer pageSize);

 //--------------------- 分页插件写法---------------------------
//    @Select("select e.*,d.name deptName from emp e left join dept d " +
//            "on e.dept_id = d.id order by update_time desc ")
    public List<Emp> list(String name, Integer gender, LocalDate begin, LocalDate end);

    @Options(useGeneratedKeys = true,keyProperty = "id")
@Insert("insert into emp(username,password,name,gender,phone,job,salary,image,entry_date,dept_id,create_time,update_time)"+
        "values (#{username},#{password},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    public void save(Emp emp);


    void delete(List<Integer> ids);

    Emp getInfor(Integer id);
}
